﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace AIG.MARS.Forms.MarsFormsWebPart
{
    [ToolboxItemAttribute(false)]
    public class MarsFormsWebPart : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/15/AIG.MARS.Forms/MarsFormsWebPart/MarsFormsWebPartUserControl.ascx";

//        protected override void Render(HtmlTextWriter writer)
//        {
//            base.Render(writer);
//            if (SPContext.Current.FormContext.FormMode != Microsoft.SharePoint.WebControls.SPControlMode.Edit)
//            {
//                writer.Write(@"<script>
//                    $().ready(function() {
//                        $(""#" + this.Page.Form.ClientID + @""").validate({
//                        rules: {
//                            ModelSubmitter: {
//                                required: true
//                            }
//                        },
//                        messages: {
//                            ModelSubmitter: {
//                                required: 'Model Name is required.'
//                            }
//                        }
//                    });
//                    });
//                    </script>");
//            }
//        }
        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
        }
    }
}
